package com.belf.common.config;

import org.apache.commons.lang3.concurrent.BasicThreadFactory;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.stereotype.Component;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.ScheduledThreadPoolExecutor;

@Component
public class ThreadPool  implements InitializingBean {

    private ExecutorService executorService;

    @Override
    public void afterPropertiesSet() {
        this.executorService  = new ScheduledThreadPoolExecutor(20,
                new BasicThreadFactory.Builder().namingPattern("export-Thread-%d").daemon(true).build());
    }

    public ExecutorService getExecutorService() {
        return executorService;
    }
}
